<!DOCTYPE html><html><head>
{php $this->pmeta('商家地图'); }
{php}
eimp('initJs','jquery;bootstrap;comm');
eimp('initCss','bootstrap,stpub;comm;info'); 

$db = db();

// 参数
$mods = array('company','govern','organize');
$mod = req('mod');
$mod = in_array($mod, $mods) ? $mod : 'company';
$ftype = req('ftype');
// 分页
$sfrom = "uid,company,ftype,map FROM {$db->pre}users_{$mod}$db->ext ";
$where = "`show`=1 AND map>'0' ".($ftype ? " AND ftype='$ftype' " : ''); 
$pg = new comPager($sfrom,$where,2,"atime"); 
$pg->set('opkey','0');
$rs = $pg->exe(); 
// 数据
$items = array(); $idfirst = ''; $idend = '';
if($rs){
foreach($rs as $row){
    $info = array('uid'=>$row['uid'], 'title'=>$row['company']);
    $map = explode(',',$row['map']);
    $items[] = $info + $map;  
}}
$ubase = basReq::getUri(-1,'','page|prec|ptype|pkey');
$pabar = $pg->show($idfirst,$idend,'',$ubase);

{/php}
<style type="text/css">
#allmap { height:600px; overflow:hidden; margin:10px 3px; border:1px solid #CCC; }
label { max-width:none; opacity:0.7; border:1px dotted #CCC; border-radius:3px; }
</style>
<script src="http://api.map.baidu.com/api?v=2.0&ak={=$_cbase['3aks']['baiduip']}"></script>
</head><body>

<?php

?>
{inc:"c_pub/ahead"}
{inc:"c_pub/amenu"}


<div class="row">
  <div class="col-md-9">

    <div class="info-tbar">
    <i>商家地图</i>
    <i class="right">
        {php}
            foreach($mods as $xmod){
                echo "<a href='?{$this->mkv}&mod=$xmod'>$xmod</a>";
            }
        {/php}
    </i>
    </div>
    类别
    {tag:utab=[Type][modid,ftype][limit,88]}
        &middot; <a href="?{=$this->mkv}&ftype={=$t_kid}">{=$t_title}</a>
    {/tag:utab}

    <div class="tc">
    <!--main_start-->
      <!--map_start-->
      <div id="allmap">-</div>
      <!--map_end-->
      <div class='pg_bar'>{=$pabar}</div>
    <!--main_end-->
    </div>
  </div>
  <div class="col-md-3">

    <div class="sd-so01">
    <form method="get" action="{surl(0:0)}">
    <input name="{=$this->mkv}" type="hidden" value="">
    <input name="pid" type="hidden" value="{=$pid}">
    <input name="keywd" type="text" id="keywd" class="w150" />
    <input type="submit" id="sobtn" value="搜索" />
    </form>
    </div>
    {inc:"info/a-side"}
  </div>
</div>


{inc:"c_pub/afoot"} 

<script>
var users = <?=comParse::jsonEncode($items)?>;
var point = new BMap.Point(110.776601, 30.384464);
function addMarker(point, row){
  var marker = new BMap.Marker(point);
  var label = new BMap.Label(row['title'],{offset:new BMap.Size(20,-10)});
  marker.setLabel(label);
  map.addOverlay(marker);
}
var points = new Array();
for (var i=0; i<users.length; i++) {
    var point = new BMap.Point(parseFloat(users[i][0]), parseFloat(users[i][1]));
    points.push(point);
}
var map = new BMap.Map("allmap");
map.centerAndZoom(point, 5);
map.addControl(new BMap.NavigationControl({type:BMAP_NAVIGATION_CONTROL_ZOOM})); //缩放
map.addControl(new BMap.ScaleControl()); // 比例尺
map.addControl(new BMap.MapTypeControl()); //添加地图类型控件
map.enableScrollWheelZoom();
var v = map.getViewport(points); 
map.centerAndZoom(v.center, v.zoom);
for (var i=0; i<users.length; i++) {
    addMarker(points[i], users[i]);
}
</script>

</body></html>

